package general;

import java.io.File;

import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

import constants.ConfigurationConstants;

public class WebDriverUtil {

	public static FirefoxDriver getFirefoxDriver() {
		return new FirefoxDriver();
	}

	public static InternetExplorerDriver getInternetExplorerDriver() {
		
		File file = new File(LoadPropertiesUtil.getInstance().getProperty(
				ConfigurationConstants.PATH_IE_DRIVER));

		System.setProperty(
				LoadPropertiesUtil.getInstance().getProperty(
						ConfigurationConstants.SYSTEM_PROPERTY_IE),
				file.getAbsolutePath());

		DesiredCapabilities capabilities = new DesiredCapabilities();

		capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
		capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);

		return new InternetExplorerDriver(capabilities);
	}

	public static ChromeDriver getChromeDriver() {
		File file = new File(LoadPropertiesUtil.getInstance().getProperty(
				ConfigurationConstants.PATH_CHROME_DRIVER));

		System.setProperty(
				LoadPropertiesUtil.getInstance().getProperty(
						ConfigurationConstants.SYSTEM_PROPERTY_CHROME),
				file.getAbsolutePath());

		return new ChromeDriver();
	}

}
